package de.windeln.marketing.campaign.costinterval.services;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Required;

import de.windeln.marketing.campaign.costinterval.dao.interfaces.CostIntervalMapper;
import de.windeln.marketing.campaign.costinterval.model.CostintervalClientObject;
import de.windeln.marketing.campaign.costinterval.services.interfaces.CostIntervalService;


public class DefaultCostIntervalService implements CostIntervalService {

	
	private CostIntervalMapper costIntervalMapper;
	
	@Override
	public List<Map<String, Object>> fetchAllCostIntervalForCampaign(int id) {
		return costIntervalMapper.fetchAllCostIntervalForCampaign(id);
	}


	@Override
	public void insertNewCostInterval(CostintervalClientObject costInterval) {
		costIntervalMapper.insertNewCostInterval(costInterval);
	}

	@Override
	public void deleteCostInterval(Long costintervalId) {
		costIntervalMapper.updateCostIntervalToDeleteState(costintervalId);	
	}

	@Override
	public void deleteCostIntervalByCampaignId(Long campaignId) {
		costIntervalMapper.updateCostIntervalToDeleteStateByCampaignId(campaignId);
		
	}
	
	@Override
	public void editCostInterval(CostintervalClientObject costInterval) {
		deleteCostInterval(costInterval.getId());
		costIntervalMapper.insertNewCostInterval(costInterval);
	}
	
	@Required
	public void setCostIntervalMapper(CostIntervalMapper costIntervalMapper) {
		this.costIntervalMapper = costIntervalMapper;
	}


	@Override
	public Date findCampaignStartByCampaignId(long campaignId) {
		return costIntervalMapper.findCampaignStartByCampaignId(campaignId);
	}


	@Override
	public Date findCampaignEndByCampaignId(long campaignId) {
		return costIntervalMapper.findCampaignEndByCampaignId(campaignId);
	}


	@Override
	public List<Map<String, Object>> findAllCostintervalDatesByCampaignId(long campaignId) {
		return costIntervalMapper.findAllCostintervalDatesByCampaignId(campaignId);
	}


	
}
